<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text">
    <button>点我</button>
    <script>
        var text = document.querySelector('input[type="text"]');
        var btn = document.querySelector('button');

        text.onchange = function() {
            console.log('我变了');
        }

        btn.onclick = function() {
            text.value = '1111';
        }

        var obj = {
            list: 'info',
            translate: {
                trashed: '回收站',
                published: '已发布',
                drafted: '草稿'
            },

            fixDate: function(time) {
                time = time.split(' ')[0];
                while (time.indexOf('-') != -1) {
                    time = time.replace('-', '/')
                }

                console.log(this.translate);
                return time;
            }
        }

        obj.fixDate('asdsad');

        // 说明事件的触发，只能通过模拟来触发，这里给text通过代码设置值，并不会触发text.onchange事件
    </script>
</body>

</html>